package com.example.huangyuchen.advance.training.camp.builder;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;

import java.io.Serializable;

/**
 * @author YuChen Huang
 */
@FieldDefaults(level = AccessLevel.PRIVATE)
@Getter
public class DetailTwo extends BaseDomain implements Serializable {

    public static final int DEFAULT_SEQUENCE = 0;

    /**
     * 收货单ID
     */
    private Long orderId;

    /**
     * 生产日期
     */
    private Long productionDate;

    /**
     * 保质期
     */
    private Long shelfLifeDays;

    /**
     * 过期日期
     */
    private Long expiryDate;

    protected DetailTwo(DetailTwoBuilder<?, ?> b) {
        super(b);
        this.orderId = b.orderId;
        this.productionDate = b.productionDate;
        this.shelfLifeDays = b.shelfLifeDays;
        this.expiryDate = b.expiryDate;
    }

    public static DetailTwoBuilder<?, ?> builder() {
        return new DetailTwoBuilderImpl();
    }


    public static abstract class DetailTwoBuilder<C extends DetailTwo, B extends DetailTwoBuilder<C, B>> extends BaseDomainBuilder<C, B> {
        private Long orderId;
        private Long productionDate;
        private Long shelfLifeDays;
        private Long expiryDate;

        public B orderId(Long orderId) {
            this.orderId = orderId;
            return self();
        }

        public B productionDate(Long productionDate) {
            this.productionDate = productionDate;
            return self();
        }

        public B shelfLifeDays(Long shelfLifeDays) {
            this.shelfLifeDays = shelfLifeDays;
            return self();
        }

        public B expiryDate(Long expiryDate) {
            this.expiryDate = expiryDate;
            return self();
        }

        protected abstract B self();

        public abstract C build();

        public String toString() {
            return "DetailTwo.DetailTwoBuilder(super=" + super.toString() + ", orderId=" + this.orderId + ", productionDate=" + this.productionDate + ", shelfLifeDays=" + this.shelfLifeDays + ", expiryDate=" + this.expiryDate + ")";
        }
    }

    private static final class DetailTwoBuilderImpl extends DetailTwoBuilder<DetailTwo, DetailTwoBuilderImpl> {

        DetailTwoBuilder<DetailTwo, DetailTwoBuilderImpl> builder = this;
        BaseDomainBuilder<DetailTwo, DetailTwoBuilderImpl> parentBuilder = builder;

        private DetailTwoBuilderImpl() {
        }

        @Override
        protected DetailTwoBuilderImpl self() {
            return this;
        }

        @Override
        public DetailTwoBuilderImpl orderId(Long orderId) {



            return super.orderId(orderId);
        }

        @Override
        public DetailTwo build() {
            final Long orderId = builder.orderId;
            return new DetailTwo(this);
        }
    }
}